<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>
    <style>
        .input, form+a {
            margin: 20px 20px;
            width: 250px;
        }
        .input>label {
            display: inline-block;
            width: 80px;
            text-align: right;
        }
        .input:last-child {
            text-align: center;
        }
        input[type=text], input[type=password] {
            outline: none;
        }
        input[type=submit], input[type=reset] {
            width: 60px;
        }
        form+a {
            text-decoration: none;
            color: blue;
        }
        .hint {
            margin-left: 20px;
            color: red;
            font-size: 0.8em;
            height: 20px;
        }
        .mobile {
            width: 300px;
        }
    </style>
</head>
<body>
    <h1>用户注册</h1>
    <hr>
    <p class="hint">{{ hint }}</p>
    <form action="/vote/register/" method="post">
        {% csrf_token %}
        <div class="input">
            <label>用户名：</label>
            <input type="text" name="username" required minlength="4" maxlength="20">
        </div>
        <div class="input">
            <label>密码：</label>
            <input type="password" name="password">
        </div>
        <div class="input">
            <label>确认密码：</label>
            <input type="password" name="repassword">
        </div>
        <div class="input mobile">
            <label>手机号：</label>
            <input type="tel" name="tel">
            <input type="button" id="sendBtn" value="发送验证码">
        </div>
        <div class="input">
            <label>验证码：</label>
            <input type="text" name="mobilecode">
        </div>
        <div class="input">
            <input type="submit" value="注册">
            <input type="reset" value="重置">
        </div>
    </form>
    <a href="/vote/login/">返回登录</a>
    <script src={{"https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"}}></script>
    <script>
        $(() => {
            $('#sendBtn').on('click', (evt) => {
                let tel = $(evt.target).prev().val()
                <!-- url/?后面跟参数叫:查询参数,如果有多组参数用&符号链接-->
                <!-- url后面跟参数叫:路径参数>
                $.getJSON('/vote/mobile/' + tel, (json) => {

                })
            })
        })
    </script>
</body>
</html>